-- delete from cv_work
INSERT INTO cv_work
SELECT 
case len(convert(varchar(10),id))
	when 6 then '00000000-0000-0000-0000-000000' + convert(varchar(10),id) 
    when 5 then '00000000-0000-0000-0000-0000000' + convert(varchar(10),id) 
    when 4 then '00000000-0000-0000-0000-00000000' + convert(varchar(10),id) 
    when 3 then '00000000-0000-0000-0000-000000000' + convert(varchar(10),id) 
    when 2 then '00000000-0000-0000-0000-0000000000' + convert(varchar(10),id) 
    when 1 then '00000000-0000-0000-0000-00000000000'+ convert(varchar(10),id) 
    end As Id,[companyname] AS [CompanyName],begindate AS [StartDate],enddate AS [EndDate],companyproperty AS [CompanyType],companyindustry AS [Industry],comdepartment AS [Department],fstjobid AS [Category1],sndjobid AS [Category2],comotherposition AS [JobTitle],workdiscription AS [Description],0 AS [IsOverseas],0 AS [IsShielded],'00000000-0000-0000-0000-00000' + convert(varchar(7),resumeid) AS  [ResumeId],CreatedDate AS [DateCreated],UpdatedDate AS [LastUpdated]FROM srv_lnk.nchr2008.dbo.PersonWorkExp
where resumeid in (select right(id,7) from cv_resume)




--SELECT max(id) FROM srv_lnk.nchr2008.dbo.PersonWorkExp
--SELECT count(*) FROM srv_lnk.nchr2008.dbo.PersonWorkExp where flag = 1


